from selenium import webdriver
import json
import time

driver = webdriver.Edge(executable_path="./driver/msedgedriver.exe")
driver.get("https://app.buaa.edu.cn/uc/wap/login?redirect=https%3A%2F%2Fapp.buaa.edu.cn%2Fsite%2FbuaaStudentNcov%2Findex")
print(driver.get_cookies())
cookie_1 = {'domain': 'app.buaa.edu.cn', 'httpOnly': False, 'name': 'xxbh21.8', 'path': '/', 'secure': False, 'value': '56842922'}
cookie_2 = {'domain': 'app.buaa.edu.cn', 'expiry': 1621090691, 'httpOnly': True, 'name': 'eai-sess', 'path': '/', 'secure': False, 'value': 'gmusqjb4rg0hsf1pt9tcln3vh0'}
driver.delete_all_cookies()
driver.add_cookie(cookie_1)
driver.add_cookie(cookie_2)
time.sleep(2)
driver.get("https://app.buaa.edu.cn/site/buaaStudentNcov/index")
# inputList = driver.find_elements_by_tag_name("input")
# pressbutton = driver.find_element_by_class_name("btn")
# try:
#     with open("password.txt","r") as f:
#         load = json.load(f)
#     username = load["username"]
#     password = load["password"]
# except:
#     username = input("username: ")
#     password = input("password: ")
#     d = {"username":username,"password":password}
#     with open("password.txt","w") as f:
#         json.dump(d,f)

# inputList[0].send_keys(username)
# inputList[1].send_keys(password)
# pressbutton.click()

# print(driver.get_cookies())

if __name__ =="__main__":
    pass